package com.yjd.bi.jf.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yjd.bi.jf.dao.IJfIntegralDataDao;
import com.yjd.bi.jf.enums.JfIntegralDataIncrEnum;
import com.yjd.bi.jf.enums.JfIntegralDataRefTableEnum;
import com.yjd.bi.jf.enums.JfIntegralDataType;
import com.yjd.bi.jf.model.JfIntegralDataModel;
import com.yjd.bi.jf.service.IJfIntegralDataService;
import com.yjd.bi.jf.service.IJfIntegralService;
import com.yjd.bi.jf.service.IJfIntegralYearService;
import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.enums.UserEnums;

/**
 * <b>description</b>：会员积分流水表业务实现<br>
 * <b>time</b>：2017-03-07 15:09:16 <br>
 * <b>author</b>： ready percy-chen@hotmail.com
 */
@Service("jfIntegralDataService")
public class JfIntegralDataServiceImpl extends BaseServiceImpl implements
	IJfIntegralDataService {
    /**
     * 插入
     * 
     * @param model
     * @return
     * @throws Exception
     */
    public JfIntegralDataModel insert(JfIntegralDataModel model)
	    throws Exception {
	return this.jfIntegralDataDao.insertModel(model, true);
    }

    /**
     * 更新
     * 
     * @param model
     * @return
     * @throws Exception
     */
    public int update(JfIntegralDataModel model) throws Exception {
	return this.jfIntegralDataDao.updateModel(model, true);
    }

    /**
     * 根据id删除
     * 
     * @param id
     * @return
     * @throws Exception
     */
    public int delete(long id) throws Exception {
	Map<Object, Object> paramMap = new HashMap<Object, Object>();
	paramMap.put("id", id);
	return this.jfIntegralDataDao.deleteModel(paramMap, true);
    }

    /**
     * 
     * 插入流水,记账
     * 
     * @param user_id
     *            用户id
     * @param amount
     *            数量
     * @param channel
     *            渠道
     * @param income
     *            方向(+1加 -1 减)
     * @param type
     *            类型
     * @param refTableEnum
     *            关联表
     * @param refid
     *            关联id
     * @param optTime
     *            业务操作时间
     * @param currTime
     *            系统处理时间
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public void add(Long user_id, Integer amount, UserEnums.Channel channel,
	    JfIntegralDataIncrEnum income, JfIntegralDataType type,
	    JfIntegralDataRefTableEnum refTableEnum, Long refid, Long optTime,
	    Long currTime) throws Exception {
    }

    @Resource
    private IJfIntegralDataDao jfIntegralDataDao;

    @Resource
    private IJfIntegralService jfIntegralService;

    @Resource
    private IJfIntegralYearService jfIntegralYearService;

    @Override
    public IBaseDao getBaseDao() {
	return this.jfIntegralDataDao;
    }

}
